<?php $user = $this->user?>
<?php $myCartObj = new Cart(); $myCartInfo = $myCartObj->getMyCart();$siteConfig=new Config("site_config");?>
<?php $siteConfigObj = new Config("site_config");$site_config   = $siteConfigObj->getInfo();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $siteConfig->name;?></title>
<link type="image/x-icon" href="favicon.ico" rel="icon">
<link type="image/x-icon" href="favicon.ico" rel="bookmark">
<link rel="stylesheet" href="<?php echo IUrl::creatUrl("")."views/".$this->theme."/skin/".$this->skin."/css/index.css";?>" />
<link rel="stylesheet" href="<?php echo IUrl::creatUrl("")."views/".$this->theme."/skin/".$this->skin."/css/jquery.jqzoom.css";?>" />
<script charset="UTF-8" src="/shop/runtime/systemjs/jquery-1.4.4.min.js"></script>
<script charset="UTF-8" src="/shop/runtime/systemjs/form.js"></script>
<link rel="stylesheet" type="text/css" href="/shop/runtime/systemjs/autovalidate/style.css"/><script charset="UTF-8" src="/shop/runtime/systemjs/autovalidate/validate.js"></script>
<script charset="UTF-8" src="/shop/runtime/systemjs/artdialog/artDialog.min.js"></script>
<script type='text/javascript' src="<?php echo IUrl::creatUrl("")."views/".$this->theme."/javascript/common.js";?>"></script>
<script type='text/javascript' src="<?php echo IUrl::creatUrl("/javascript/adloader/");?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo IUrl::creatUrl("")."views/".$this->theme."/skin/".$this->skin."/";?>jquery.bxSlider/bx_styles/bx_styles.css" />
</head>
<body class="index">
<div class="container">
	<div class="header">
		<h1 class="logo"><a title="<?php echo $siteConfig->name;?>" style="background:url(<?php echo IUrl::creatUrl("")."image/logo.gif";?>);" href="<?php echo IUrl::creatUrl("");?>"><?php echo $siteConfig->name;?></a></h1>
		<ul class="shortcut">
			<li class="first"><a href="<?php echo IUrl::creatUrl("/ucenter/index");?>">我的账户</a></li><li><a href="<?php echo IUrl::creatUrl("/ucenter/order");?>">我的订单</a></li><li class='last'><a href="<?php echo IUrl::creatUrl("/site/help_list");?>">使用帮助</a></li>
		</ul>
		<p class="loginfo">
			<?php if((isset($user['user_id']) && $user['user_id']!='')){?><?php echo isset($user['username'])?$user['username']:"";?>您好，欢迎您来到<?php echo $siteConfig->name;?>购物！[<a href="<?php echo IUrl::creatUrl("/simple/logout");?>" class="reg">安全退出</a>]<?php }else{?>[<a href="<?php echo IUrl::creatUrl("/simple/login");?>">登录</a>
			<?php $callback = IReq::get('callback')?>
			<?php if($callback==""){?>
			<a class="reg" href="<?php echo IUrl::creatUrl("/simple/reg");?>">免费注册</a>
			<?php }else{?>
			<?php $callback=urlencode($callback);?>
			<a class="reg" href="<?php echo IUrl::creatUrl("/simple/reg/?callback=$callback");?>">免费注册</a>
			<?php }?>
			]
			<?php }?>
		</p>
	</div>
	<div class="navbar">
		<ul>
			<li><a href="<?php echo IUrl::creatUrl("");?>">首页</a></li>
			<?php $i=0;?>
			<?php $query = new IQuery("guide");$items = $query->find(); foreach($items as $key => $item){?>
			<?php $i++;$item['link']=IUrl::creatUrl($item['link']);?>
			<li <?php if($i==count($items)){?>style="background:none;"<?php }?>><a href="<?php echo isset($item['link'])?$item['link']:"";?>"><?php echo isset($item['name'])?$item['name']:"";?><span> </span></a></li>
			<?php }?>
		</ul>

		<div class="mycart">
			<dl>
				<dt><a href="<?php echo IUrl::creatUrl("/simple/cart");?>">购物车<b name="mycart_count"><?php echo isset($myCartInfo['count'])?$myCartInfo['count']:"";?></b>件</a></dt>
				<dd><a href="<?php echo IUrl::creatUrl("/simple/cart");?>">去结算</a></dd>
			</dl>

			<!--购物车浮动div 开始-->
			<div class="shopping" id='div_mycart' style='display:none;'>
			</div>
			<!--购物车浮动div 结束-->

		</div>
	</div>

	<div class="searchbar">
		<div class="allsort">
			<a href="javascript:void(0);">全部商品分类</a>

			<!--总的商品分类-开始-->
			<ul class="sortlist" id='div_allsort' style='display:none'>
				<?php $this->goodsCategory = block::goods_category();?>
				<?php foreach($this->goodsCategory as $key => $first){?>
					<li>
						<h2><a href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$first[id]");?>"><?php echo isset($first['name'])?$first['name']:"";?></a></h2>

						<!--商品分类 浮动div 开始-->
						<div class="sublist" style='display:none'>

							<div class="items">
								<strong>选择分类</strong>
								<?php if(isset($first['second'])){?>
								<?php foreach($first['second'] as $key => $second){?>
								<dl class="category selected">
									<dt>
										<a href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$second[id]");?>"><?php echo isset($second['name'])?$second['name']:"";?></a>
									</dt>

									<dd>
										<?php if(isset($second['more'])){?>
										<?php foreach($second['more'] as $key => $third){?>
										<a href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$third[id]");?>"><?php echo isset($third['name'])?$third['name']:"";?></a>|
										<?php }?>
										<?php }?>
									</dd>
								</dl>
								<?php }?>
								<?php }?>

							</div>

						</div>
						<!--商品分类 浮动div 结束-->

					</li>
				<?php }?>

			</ul>
			<!--总的商品分类-结束-->

		</div>

		<div class="searchbox">
			<form method='get'>
				<input type='hidden' name='controller' value='site' />
				<input type='hidden' name='action' value='search_list' />
				<?php $word = IReq::get('word');?>
				<input class="text" type="text" name='word' id="word" autocomplete="off" value="<?php echo $word ? $word : '输入关键字...';?>" />
				<input class="btn" type="submit" value="商品搜索" onclick="checkInput('word','输入关键字...');" />
			</form>

			<!--自动完成div 开始-->
			<ul class="auto_list" style='display:none'></ul>
			<!--自动完成div 开始-->

		</div>
		<div class="hotwords">热门搜索：
			<?php $query = new IQuery("keyword");$query->where = "hot = 1";$query->limit = "5";$query->order = "`order` asc";$items = $query->find(); foreach($items as $key => $item){?>
			<?php $tmpWord = urlencode($item['word']);?>
			<a href="<?php echo IUrl::creatUrl("/site/search_list/word/$tmpWord");?>"><?php echo isset($item['word'])?$item['word']:"";?></a>
			<?php }?>
		</div>
	</div>
	<div class="m_10" id="adHere_1"></div>
	<script language="javascript">
	(new adLoader()).load(1,'adHere_1');
	</script>

		<div class="position"> <span>您当前的位置：</span> <a href="<?php echo IUrl::creatUrl("");?>"> 首页</a> » 站点地图 </div>
	<div class="sitemap wrapper clearfix">
		<div class="orange_title"><strong>服务</strong></div>
		<ul class="service_list clearfix">
			<li><a class="s1" href="<?php echo IUrl::creatUrl("/simple/reg");?>">注册</a></li><li><a class="s2" href="<?php echo IUrl::creatUrl("/simple/login");?>">登录</a></li><li><a class="s3" href="<?php echo IUrl::creatUrl("/site/article");?>">shop资讯</a></li><li><a class="s4" href="<?php echo IUrl::creatUrl("/site/groupon");?>">团购</a></li><!--<li><a class="s5" href="">限时抢购</a></li>--><li><a class="s6" href="<?php echo IUrl::creatUrl("/site/tags");?>">热门标签</a></li><li><a class="s7" href="<?php echo IUrl::creatUrl("/simple/cart");?>">购物车</a></li><li><a class="s8" href="<?php echo IUrl::creatUrl("site/sitemap");?>">网站地图</a></li><li><a class="s9" href="<?php echo IUrl::creatUrl("/site/notice");?>">站点公告</a></li><li><a class="s10" href="<?php echo IUrl::creatUrl("/site/help_list");?>">帮助中心</a></li><li><a class="s11" href="<?php echo IUrl::creatUrl("/simple/find_password");?>">找回密码</a></li>
		</ul>
		<div class="box">
			<div class="title"><h2>所有商品分类</h2></div>

			<div class="sort_1">
				<?php foreach($this->goodsCategory as $key => $item){?>
				<a onclick="$(this).siblings().removeClass('current');$(this).addClass('current');" href="#sort_<?php echo isset($key)?$key:"";?>"><?php echo isset($item['name'])?$item['name']:"";?></a>
				<?php }?>
			</div>
			<div class="sort_2">

				<?php foreach($this->goodsCategory as $key => $first){?>
				<table class="form_table" width="100%">
					<col width="100px" />
					<col />
					<caption><a name="sort_<?php echo isset($key)?$key:"";?>"><?php echo isset($first['name'])?$first['name']:"";?></a></caption>
					<tbody>
						<?php if(isset($first['second'])){?>
						<?php foreach($first['second'] as $key => $second){?>
						<tr>
							<th><a class="current" href="<?php echo IUrl::creatUrl("/site/pro_list/cat/$second[id]");?>"><?php echo isset($second['name'])?$second['name']:"";?></a></th>
							<td>
								<?php if(isset($second['more'])){?>
								<?php foreach($second['more'] as $key => $more){?>
								<a href='<?php echo IUrl::creatUrl("/site/pro_list/cat/$second[id]");?>'><?php echo isset($more['name'])?$more['name']:"";?></a>
								<?php }?>
								<?php }?>
							</td>
						</tr>
						<?php }?>
						<?php }?>
						<tr><th></th><td><a class="top f_r blue" href="#">回到顶部</a></td></tr>
					</tbody>
				</table>
				<?php }?>

			</div>
		</div>
	</div>


	<div class="help m_10">
		<div class="cont clearfix">
			<?php $cat_list=array();?>
			<?php $query = new IQuery("help_category AS cat");$query->where = "position_foot = 1";$query->order = "sort ASC,id desc";$query->limit = "5";$items = $query->find(); foreach($items as $key => $item){?>
			<?php $cat_list[$item['id']]=$item;?>
			<?php }?>
			<?php if(count($cat_list)){?>
				<?php $width=floor(100/count($cat_list))-1;?>
			<?php }?>

			<?php foreach($cat_list as $cat_id => $cat){?>
			<dl style="width:<?php echo isset($width)?$width:"";?>%">
     			<dt><a href="<?php echo IUrl::creatUrl("/site/help_list/id/$cat[id]");?>"><?php echo isset($cat['name'])?$cat['name']:"";?></a></dt>
     			<?php $query = new IQuery("help");$query->where = "cat_id = $cat_id";$query->order = "sort ASC,id desc";$items = $query->find(); foreach($items as $key => $item){?>
					<dd><a href="<?php echo IUrl::creatUrl("/site/help/id/$item[id]");?>"><?php echo isset($item['name'])?$item['name']:"";?></a></dd>
				<?php }?>
      		</dl>
      		<?php }?>
		</div>
	</div>
	<?php echo $siteConfig->site_footer_code;?>
</div>
<script type='text/javascript' src='<?php echo IUrl::creatUrl("")."views/".$this->theme."/javascript/site.js";?>'></script>
<script type='text/javascript'>
	$('input:text[name="word"]').bind({
		keyup:function(){autoComplete('<?php echo IUrl::creatUrl("/site/autoComplete");?>','<?php echo IUrl::creatUrl("/site/search_list/word/@word@");?>','<?php echo isset($site_config['auto_finish'])?$site_config['auto_finish']:"";?>');}
	});

	var mycartLateCall = new lateCall(200,function(){showCart('<?php echo IUrl::creatUrl("/simple/showCart");?>')});

	//购物车div层
	$('.mycart').hover(
		function(){
			mycartLateCall.start();
		},
		function(){
			mycartLateCall.stop();
			$('#div_mycart').hide('slow');
		}
	);

	//[ajax]加入购物车
	function joinCart_ajax(id,type)
	{
		var url ="<?php echo IUrl::creatUrl("/simple/joinCart/random/@random@/goods_id/@goods_id@/type/@type@");?>";
		url = url.replace("@random@",Math.random()).replace("@goods_id@",id).replace("@type@",type);
		$.getJSON(url,function(content){
			if(content.isError == false)
			{
				var count = parseInt($('[name="mycart_count"]').html());
				$('[name="mycart_count"]').html(count + 1);
				$('.msgbox').hide();
				alert(content.message);
			}
			else
			{
				alert(content.message);
			}
		});
	}

	//列表页加入购物车统一接口
	function joinCart_list(id)
	{
		var url = "<?php echo IUrl::creatUrl("/simple/getProducts/id/@id@");?>";
		$.get('<?php echo IUrl::creatUrl("/simple/getProducts");?>',{id:id},function(content){
			if(content == '')
			{
				joinCart_ajax(id,'goods');
			}
			else
			{
				$('#product_box_'+id).html(content);
				$('#product_box_'+id).parent().show();
			}
		});
	}
</script>
</body>
</html>
